package edu.hawaii.myisern.action;

//import java.math.BigInteger;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.StringTokenizer;
import edu.hawaii.myisern.model.Model;
import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;

/**
 * Simple ActionBean implementation that all ActionBeans in the MyIsern class will extend.
 * 
 * @author Tim Fennell
 * @author Randy Cox
 */
/**
 * @author Randy Cox
 * 
 */
public abstract class MyIsernActionBean implements ActionBean {

  private ActionBeanContext context;

  /** Model object. */
  protected Model model = Model.getInstance();

  /**
   * Sets context of web session.
   * 
   * @param context instance.
   */
  public void setContext(ActionBeanContext context) {
    this.context = context;
  }

  /**
   * Gets the ActionBeanContext set by Stripes during initialization.
   * 
   * @return context instance
   */
  public ActionBeanContext getContext() {
    return this.context;
  }

  // /**
  // * Build comma delimited string.
  // * @param list list of strings
  // * @return comma delimited string.
  // */
  // public String buildCommaStr(List<String> list) {
  // String str = "";
  // for (String name : list) {
  // if (!str.isEmpty()) {
  // str = str.concat(", ");
  // }
  // str = str.concat(name.trim());
  // }
  // return str;
  // }
  //
  // /**
  // * Build comma delimited string.
  // * @param list list of strings
  // * @return comma delimited string.
  // */
  // public String buildCommaStrBigInteger(List<BigInteger> list) {
  // String str = "";
  // for (BigInteger i : list) {
  // if (!str.isEmpty()) {
  // str = str.concat(", ");
  // }
  // str = str.concat(i.toString());
  // }
  // return str;
  // }
  //  
  // /**
  // * Parses comma delimited string.
  // * @param line string of items separated by commas
  // * @return list of strings
  // */
  // public List<String> parseCommaStr(String line) {
  // List<String> list = new ArrayList<String>();
  // if (line != null) {
  // StringTokenizer st = new StringTokenizer(line, ",");
  // while (st.hasMoreTokens()) {
  // list.add(st.nextToken());
  // }
  // }
  // return list;
  // }
  //  
  // /**
  // * Parses comma delimited string to Big Integers list.
  // * @param line string of items separated by commas
  // * @return list of strings
  // * @throws NumberFormatException if string has non-numeric chars
  // */
  // public List<BigInteger> parseCommaStrBigInteger(String line)
  // throws NumberFormatException {
  // List<BigInteger> list = new ArrayList<BigInteger>();
  // if (line != null) {
  // StringTokenizer st = new StringTokenizer(line, ",");
  // while (st.hasMoreTokens()) {
  // String item = st.nextToken().trim();
  // try {
  // Integer.parseInt(item);
  // }
  // catch (NumberFormatException e) {
  // System.err.println("Year error: " + e.getMessage());
  // throw(e);
  // }
  // list.add(new BigInteger(item));
  // }
  // }
  // return list;
  // }
  //
  // /**
  // * Include a new item in a list.
  // *
  // * @param <T> any type
  // * @param item a new item
  // * @param l a list of the appropriate type
  // */
  // protected <T> void include(T item, List<T> l) {
  // if (item != null && !"".equals(item.toString())) {
  // l.add(item);
  // }
  // }
}
